package popple.core.renders
{
	import com.popple.d3dfiles.animation.data.Bone;
	
	import flash.display3D.Context3D;
	import flash.display3D.Context3DProgramType;
	import flash.events.IEventDispatcher;
	import flash.geom.Matrix3D;
	
	public class SkinnMeshRender extends BaseRender
	{
		protected var m_bone:Vector.<Number>;
		protected var m_weight:Vector.<Number>;
		public function SkinnMeshRender(context:Context3D):void
		{
			super(context);
			
		}
		override protected function setAGALCode():void
		{
			var agalVertexSource:String=
				"m44 vt0, va0, vc[va3.x] \n" +
				"mul vt0.xyz, vt0.xyz,va4.x\n"+
				"mov vt1,vt0\n"+
				
				"m44 vt0, va0, vc[va3.y] \n" +
				"mul vt0.xyz, vt0.xyz,va4.y\n"+
				"add vt1,vt1,vt0\n"+
				
				"m44 vt0, va0, vc[va3.z] \n" +
				"mul vt0.xyz, vt0.xyz,va4.z\n"+
				"add vt1,vt1,vt0\n"+
				
				"m44 vt1, vt1, vc0\n" +
				"m44 op, vt1,vc4\n"+
				"mov v1, va1\n"+
				"mov v2, va2";
			
			var agalFragmentSource:String=
				"tex ft1, v0, fs0 <2d,clamp,linear> \n"+
				"add ft2,ft1,fc0\n"+
				"mov oc ft2";
			mVertexSource=agalVertexSource;
			mFragmentSource=agalFragmentSource;
		}
		public function setBones(bones:Vector.<Bone>):void
		{
			var firstPos:uint=3*4;
			for(var i:uint=0;i<bones.length;i++)
			{
				var bone:Bone=bones[i];
				context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX,firstPos+i*4,bone.data,true);
			}
		}
		public function render():void
		{
			/*context.clear();
			context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX,4,camera,true);
			for(var i:uint=0;i<jobs.length;i++)
			{
				var job:RenderJob=jobs[i];
				if(job.texture!=mTexture)
				{
					context.setTextureAt(0,job.texture);
					mTexture=job.texture;
				}
				if(job.vertexBuffer!=mVertexBuffer)
				{
					context.setVertexBufferAt(0,job.vertexBuffer,0,"float3");
					mVertexBuffer=job.vertexBuffer;
				}
				if(job.uvBuffer!=mUVBuffer)
				{
					context.setVertexBufferAt(1,job.uvBuffer,0,"float2");
					mUVBuffer=job.uvBuffer;
				}
				if(job.indexBuffer!=mIndexBuffer)
				{
					mIndexBuffer=job.indexBuffer;
				}
				context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX,0,job.worldMatrix,true);
				context.drawTriangles(job.indexBuffer);
			}
			context.present();*/
		}
	}
}
class Single{}